/*     */ package com.ims.iaa.JavaScript;
/*     */ 
/*     */ import com.ims.iaa.IaaUtil;
/*     */ import com.ims.iaa.URLUtil;
/*     */ import java.io.BufferedReader;
/*     */ import java.io.FileReader;
/*     */ import java.io.PrintStream;
/*     */ import java.net.URL;
/*     */ 
/*     */ public class HTMLObject
/*     */ {
/*  26 */   int SIZE = 30720;
/*  27 */   private StringBuffer m_sbJs = new StringBuffer(this.SIZE);
/*     */   private static HTMLObject m_instance;
/*  29 */   private static boolean m_bSuccess = true;
/*     */ 
/*     */   private HTMLObject()
/*     */   {
/*     */     try
/*     */     {
/*  35 */       BufferedReader jsFile = new BufferedReader(new FileReader("./resources/htmlObject.js"));
/*  36 */       char[] buf = new char[this.SIZE];
/*     */       while (true) {
/*  38 */         int moved = jsFile.read(buf);
/*  39 */         if (moved < 0) break;
/*  40 */         this.m_sbJs.append(buf, 0, moved);
/*     */       }
/*  42 */       jsFile.close();
/*  43 */       m_bSuccess = true;
/*     */     } catch (Exception e) {
/*  45 */       m_bSuccess = false;
/*  46 */       IaaUtil.printStackTrace(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   public static HTMLObject getInstance()
/*     */   {
/*  58 */     if ((m_instance == null) && (m_bSuccess)) {
/*  59 */       m_instance = new HTMLObject();
/*  60 */       if (!m_bSuccess)
/*     */       {
/*  62 */         m_instance = null;
/*     */       }
/*     */     }
/*  65 */     return m_instance;
/*     */   }
/*     */ 
/*     */   public String getObjectScript(URL url)
/*     */   {
/*  77 */     String sRet = GetLocationObject(url);
/*  78 */     sRet = sRet + this.m_sbJs.substring(0);
/*  79 */     return sRet;
/*     */   }
/*     */ 
/*     */   private String GetLocationObject(URL url)
/*     */   {
/* 101 */     String hash = "";
/* 102 */     String host = "";
/* 103 */     String hostname = "";
/* 104 */     String href = "";
/* 105 */     String pathname = "";
/* 106 */     String port = "80";
/* 107 */     String protocol = "";
/* 108 */     String search = "";
/* 109 */     if (url != null) {
/* 110 */       if (url.getHost() != null)
/* 111 */         host = url.getHost();
/* 112 */       if (url.toExternalForm() != null)
/* 113 */         href = url.toExternalForm();
/* 114 */       if (url.getPath() != null)
/* 115 */         pathname = url.getPath();
/* 116 */       if (url.getPort() > 0)
/* 117 */         port = port + url.getPort();
/* 118 */       hostname = host + ":" + port;
/* 119 */       if (url.getProtocol() != null)
/* 120 */         protocol = url.getProtocol();
/* 121 */       if (url.getQuery() != null)
/* 122 */         search = "?" + url.getQuery();
/* 123 */       if (url.getRef() != null)
/* 124 */         hash = "#" + url.getRef();
/*     */     }
/* 126 */     String var = 
/* 127 */       "var location= GetLocation();function GetLocation(){var loc = new String(\"" + 
/* 129 */       href + "\");" + 
/* 130 */       "loc.hash = \"" + hash + "\";" + 
/* 131 */       "loc.host = \"" + host + "\";" + 
/* 132 */       "loc.hostname = \"" + hostname + "\";" + 
/* 133 */       "loc.href = \"" + href + "\";" + 
/* 134 */       "loc.pathname = \"" + pathname + "\";" + 
/* 135 */       "loc.port = \"" + port + "\";" + 
/* 136 */       "loc.protocol = \"" + protocol + "\";" + 
/* 137 */       "loc.search = \"" + search + "\";" + 
/* 138 */       "return loc;" + 
/* 139 */       "}";
/* 140 */     return var;
/*     */   }
/*     */ 
/*     */   public static String getRefreshLocationStr(URL url)
/*     */   {
/* 156 */     if (url == null) {
/* 157 */       return "";
/*     */     }
/* 159 */     String hash = "";
/* 160 */     String host = "";
/* 161 */     String hostname = "";
/* 162 */     String href = "";
/* 163 */     String pathname = "";
/* 164 */     String port = "80";
/* 165 */     String protocol = "";
/* 166 */     String search = "";
/* 167 */     if (url != null) {
/* 168 */       if (url.getHost() != null)
/* 169 */         host = url.getHost();
/* 170 */       if (url.toExternalForm() != null)
/* 171 */         href = url.toExternalForm();
/* 172 */       if (url.getPath() != null)
/* 173 */         pathname = url.getPath();
/* 174 */       if (url.getPort() > 0)
/* 175 */         port = port + url.getPort();
/* 176 */       hostname = host + ":" + port;
/* 177 */       if (url.getProtocol() != null)
/* 178 */         protocol = url.getProtocol();
/* 179 */       if (url.getQuery() != null)
/* 180 */         search = "?" + url.getQuery();
/* 181 */       if (url.getRef() != null)
/* 182 */         hash = "#" + url.getRef();
/*     */     }
/* 184 */     String var = 
/* 185 */       "location.hash = \"" + hash + "\";\n" + 
/* 186 */       "location.host = \"" + host + "\";\n" + 
/* 187 */       "location.hostname = \"" + hostname + "\";\n" + 
/* 188 */       "location.href = \"" + href + "\";\n" + 
/* 189 */       "location.pathname = \"" + pathname + "\";\n" + 
/* 190 */       "location.port = \"" + port + "\";\n" + 
/* 191 */       "location.protocol = \"" + protocol + "\";\n" + 
/* 192 */       "location.search = \"" + search + "\";\n";
/* 193 */     return var;
/*     */   }
/*     */   public static void main(String[] args) {
/* 196 */     HTMLObject loc = new HTMLObject();
/*     */     try {
/* 198 */       String sLoc = loc.GetLocationObject(URLUtil.getURL("http://facilitycity.com/"));
/* 199 */       System.out.println(sLoc);
/*     */     } catch (Exception e) {
/* 201 */       e.printStackTrace();
/*     */     }
/*     */   }
/*     */ }

/* Location:           X:\Documents and Settings\Administrator\workspace\iaa_changsheng\build\lib\iaa5.0\
 * Qualified Name:     com.ims.iaa.JavaScript.HTMLObject
 * JD-Core Version:    0.5.4
 */